package ciyuan.Block;

import ciyuan.Block.Crop.Barley;
import ciyuan.Block.Crop.Garlic;
import ciyuan.Block.Crop.Pepper;
import ciyuan.Block.Crop.Tomato;
import ciyuan.Block.Machine.Stream.jygl.Jygl;
import ciyuan.Block.Machine.ddfsj.Ddfsj;
import ciyuan.Block.Machine.dlb.Dlb;
import ciyuan.Block.Machine.fkqgj.Fkqgj;
import ciyuan.Block.Machine.fsj.Fsj;
import ciyuan.Block.Machine.fyc.Fyc;
import ciyuan.Block.Machine.gl.Gl;
import ciyuan.Block.Machine.jsq;
import ciyuan.Block.Machine.jyrss;
import ciyuan.Block.Machine.lyj.Lyj;
import ciyuan.Block.Machine.pljsrl.Pljsrl;
import ciyuan.Block.Machine.rmfdj.Rmfdj;
import ciyuan.Block.Machine.ryfdj.Ryfdj;
import ciyuan.Block.Machine.st.St;
import ciyuan.Block.Machine.tcjhc.Tcjhc;
import ciyuan.Block.Machine.yjcxj.Yjcxj;
import ciyuan.Block.Machine.yyj.Yyj;
import ciyuan.Block.Machine.yyjlq.Yyjlq;
import ciyuan.Block.Mortar.MortarBlock;
import ciyuan.Block.OreBlock.*;
import ciyuan.MainClass;
import ciyuan.Utils.FluidRegisterManager;
import net.minecraft.block.Block;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

/**
 * @author 150149
 */
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class BlockRegistryManager {

    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MainClass.MODID);
    public static final RegistryObject<Block> Tomato = BLOCKS.register("tomato_block", () -> new Tomato());
    public static final RegistryObject<Block> Pepper = BLOCKS.register("pepper_block", () -> new Pepper());
    public static final RegistryObject<Block> Barley = BLOCKS.register("barley_block", () -> new Barley());
    public static final RegistryObject<Block> Pot = BLOCKS.register("pot", () -> new Pot());
    public static final RegistryObject<Block> Mortar = BLOCKS.register("mortar_block", () -> new MortarBlock());
    public static final RegistryObject<Block> Garlic = BLOCKS.register("garlic_block", () -> new Garlic());
    public static final RegistryObject<Block> SaltOre = BLOCKS.register("salt_ore", () -> new SaltOre());
    public static final RegistryObject<Block> LigniteOre = BLOCKS.register("lignite_ore", () -> new LigniteOre());
    public static final RegistryObject<Block> PyriteOre = BLOCKS.register("pyrite_ore", () -> new PyriteOre());
    public static final RegistryObject<Block> AluminiumOre = BLOCKS.register("aluminium_ore", () -> new AluminiumOre());
    public static final RegistryObject<Block> QuartzOre = BLOCKS.register("quartz_ore", () -> new QuartzOre());
    public static final RegistryObject<Block> CopperOre = BLOCKS.register("copper_ore", () -> new CopperOre());
    public static final RegistryObject<Block> TinOre = BLOCKS.register("tin_ore", () -> new TinOre());
    public static final RegistryObject<Block> AnthraciteOre = BLOCKS.register("anthracite_ore", () -> new AnthraciteOre());
    public static final RegistryObject<Block> SiliconOre = BLOCKS.register("silicon_ore", () -> new SiliconOre());
    public static final RegistryObject<Block> Concrete = BLOCKS.register("concrete", () -> new Concrete());
    public static final RegistryObject<Block> Stonepipe = BLOCKS.register("stonepipe", () -> new StonePipe());
    public static final RegistryObject<Block> refractory_brick = BLOCKS.register("refractorybrick", () -> new RefractoryBrick());
    public static final RegistryObject<Block> gun1 = BLOCKS.register("gun1", () -> new Gun1());

    public static final RegistryObject<Block> fsj = BLOCKS.register("fsj", () -> new Fsj());
    public static final RegistryObject<Block> gl = BLOCKS.register("gl", () -> new Gl());
    public static final RegistryObject<Block> jsq = BLOCKS.register("jsq", () -> new jsq());
    public static final RegistryObject<Block> jygl = BLOCKS.register("jygl", () -> new Jygl());
    public static final RegistryObject<Block> jyrss = BLOCKS.register("jyrss", () -> new jyrss());
    public static final RegistryObject<Block> st = BLOCKS.register("st", () -> new St());
    public static final RegistryObject<Block> lyj = BLOCKS.register("lyj", () -> new Lyj());
    public static final RegistryObject<Block> pljsrl = BLOCKS.register("pljsrl", () -> new Pljsrl());
    public static final RegistryObject<Block> fkqgj = BLOCKS.register("fkqgj", () -> new Fkqgj());
    public static final RegistryObject<Block> rmfdj = BLOCKS.register("rmfdj", () -> new Rmfdj());
    public static final RegistryObject<Block> dlb = BLOCKS.register("dlb", () -> new Dlb());
    public static final RegistryObject<Block> ddfsj = BLOCKS.register("ddfsj", () -> new Ddfsj());
    public static final RegistryObject<Block> yyj = BLOCKS.register("yyj", () -> new Yyj());
    public static final RegistryObject<Block> tcjhc = BLOCKS.register("tcjhc", () -> new Tcjhc());
    public static final RegistryObject<Block> yjcxj = BLOCKS.register("yjcxj", () -> new Yjcxj());
    public static final RegistryObject<Block> fyc = BLOCKS.register("fyc", () -> new Fyc());
    public static final RegistryObject<Block> yyjlq = BLOCKS.register("yyjlq", () -> new Yyjlq());
    public static final RegistryObject<Block> ryfdj = BLOCKS.register("ryfdj", () -> new Ryfdj());

    public static RegistryObject<FlowingFluidBlock> oil = BLOCKS.register("oil_fluid", () -> new FlowingFluidBlock(FluidRegisterManager.oil, Block.Properties.of(Material.WATER).noOcclusion().noDrops()));


    @SubscribeEvent
    public static void onRender(FMLClientSetupEvent event) {
        event.enqueueWork(()->{
            RenderTypeLookup.setRenderLayer(BlockRegistryManager.Tomato.get(), RenderType.cutoutMipped());
            RenderTypeLookup.setRenderLayer(BlockRegistryManager.Barley.get(), RenderType.cutoutMipped());
            RenderTypeLookup.setRenderLayer(BlockRegistryManager.Pepper.get(), RenderType.cutoutMipped());
            RenderTypeLookup.setRenderLayer(BlockRegistryManager.Garlic.get(), RenderType.cutoutMipped());
            RenderTypeLookup.setRenderLayer(FluidRegisterManager.oil.get(), RenderType.translucent());
            RenderTypeLookup.setRenderLayer(FluidRegisterManager.oilFlowing.get(), RenderType.translucent());
        });
    }

}
